/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gui;

import geracaopdf.ClienteListaPDF;
import controlador.ControladorCliente;
import controlador.ControladorCompra;
import controlador.ControladorProduto;
import controlador.ControladorTransacoes;
import geracaopdf.ClienteIndividualPDF;
import geracaopdf.ProdutosListaPDF;
import geracaopdf.TransacoesListaPDF;
import geracaopdf.TransacoesNotaDeVendaPDF;
import java.sql.Date;
import java.util.ArrayList;
import java.util.Vector;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import utils.Cliente;
import utils.Compra;
import utils.Produto;
import utils.Transacoes;

/**
 *
 * @author Igor
 */
public class PainelGeracaoDeRelatorios extends javax.swing.JPanel {

    /**
     * Creates new form PainelGeracaoDeRelatorios
     */
    ArrayList<Cliente> clientes;
    ArrayList<Transacoes> transacoes;
    ArrayList<Produto> produtos;
    ArrayList<Compra> compras;
    
    ControladorCliente controladorCliente = new ControladorCliente();
    ControladorTransacoes controladorTransacoes = new ControladorTransacoes();
    ControladorProduto controladorProduto = new ControladorProduto();
    ControladorCompra controladorCompra = new ControladorCompra();
    DefaultTableModel modelTabelaClientes;
    DefaultTableModel modelCompras;
    DefaultTableModel modelTabelaProdutos;
    
    int[] dias = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31};
    int[] meses = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
    int[] anos = {2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009, 2008, 2007, 2006, 2005, 2004, 2003, 2002, 2001, 2000};

    public PainelGeracaoDeRelatorios() {
        initComponents();
        abasRelatorio.setSelectedIndex(0);
        this.abasRelatorio.setEnabledAt(0, true);
        this.abasRelatorio.setEnabledAt(1, false);
        this.abasRelatorio.setEnabledAt(2, false);

        //aba de clientes
        campoListaPorNome.setEnabled(false);
        campoListaPorCPFCNPJ.setEnabled(false);

        //aba de transações
        campoBuscaID.setEnabled(false);
        campoBuscaCPFCNPJ.setEnabled(false);
        comboAnoFinal.setEnabled(false);
        comboAnoInicial.setEnabled(false);
        comboDiaFinal.setEnabled(false);
        comboDiaInicial.setEnabled(false);
        comboMesFinal.setEnabled(false);
        comboMesInicial.setEnabled(false);

        //aba de produtos
        campoBuscaCodigoProduto.setEnabled(false);
        campoBuscaNomeProduto.setEnabled(false);
        
        modelTabelaClientes = (DefaultTableModel) tabelaRelatorioClientes.getModel();
        modelCompras = (DefaultTableModel) tabelaComprasRelatorio.getModel();
        modelTabelaProdutos = (DefaultTableModel) tabelaProdutosRelatorio.getModel();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        barraCliente = new javax.swing.JToolBar();
        clientesRelatorio = new javax.swing.JButton();
        transacoesRelatorio = new javax.swing.JButton();
        produtosRelatorio = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        abasRelatorio = new javax.swing.JTabbedPane();
        jPanel3 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        campoListaPorNome = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        campoListaPorCPFCNPJ = new javax.swing.JTextField();
        checkPeloNome = new javax.swing.JCheckBox();
        checkPeloCPFCNPJ = new javax.swing.JCheckBox();
        jScrollPane1 = new javax.swing.JScrollPane();
        tabelaRelatorioClientes = new javax.swing.JTable();
        gerarListaPDF = new javax.swing.JButton();
        clienteIndividualPDF = new javax.swing.JButton();
        buscarClientes = new javax.swing.JButton();
        jLabel9 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tabelaComprasRelatorio = new javax.swing.JTable();
        jLabel13 = new javax.swing.JLabel();
        comboDiaInicial = new javax.swing.JComboBox();
        comboMesInicial = new javax.swing.JComboBox();
        comboAnoInicial = new javax.swing.JComboBox();
        jLabel14 = new javax.swing.JLabel();
        comboDiaFinal = new javax.swing.JComboBox();
        comboMesFinal = new javax.swing.JComboBox();
        comboAnoFinal = new javax.swing.JComboBox();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        campoBuscaID = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        campoBuscaCPFCNPJ = new javax.swing.JTextField();
        buscarCompras = new javax.swing.JButton();
        gerarNotaDeVenda = new javax.swing.JButton();
        checkIDTransacao = new javax.swing.JCheckBox();
        checkCPFCNPJTransacao = new javax.swing.JCheckBox();
        checkDataTransacoes = new javax.swing.JCheckBox();
        cancelarTransacoes = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        campoBuscaNomeProduto = new javax.swing.JTextField();
        campoBuscaCodigoProduto = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        buscarProduto = new javax.swing.JButton();
        jLabel18 = new javax.swing.JLabel();
        checkCodigoProduto = new javax.swing.JCheckBox();
        checkNomeProduto = new javax.swing.JCheckBox();
        cancelar = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        tabelaProdutosRelatorio = new javax.swing.JTable();
        listaDeProdutos = new javax.swing.JButton();

        barraCliente.setOrientation(javax.swing.SwingConstants.VERTICAL);
        barraCliente.setRollover(true);

        clientesRelatorio.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/addCliente.png"))); // NOI18N
        clientesRelatorio.setText("Clientes");
        clientesRelatorio.setFocusable(false);
        clientesRelatorio.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        clientesRelatorio.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        clientesRelatorio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                clientesRelatorioActionPerformed(evt);
            }
        });
        barraCliente.add(clientesRelatorio);

        transacoesRelatorio.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/transacoes2.png"))); // NOI18N
        transacoesRelatorio.setText("Vendas");
        transacoesRelatorio.setFocusable(false);
        transacoesRelatorio.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        transacoesRelatorio.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        transacoesRelatorio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                transacoesRelatorioActionPerformed(evt);
            }
        });
        barraCliente.add(transacoesRelatorio);

        produtosRelatorio.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/glasses.png"))); // NOI18N
        produtosRelatorio.setText("Produtos");
        produtosRelatorio.setFocusable(false);
        produtosRelatorio.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        produtosRelatorio.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        produtosRelatorio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                produtosRelatorioActionPerformed(evt);
            }
        });
        barraCliente.add(produtosRelatorio);

        jPanel1.setBackground(new java.awt.Color(0, 0, 102));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 8, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );

        jLabel6.setText("Gere lista de clientes pelo nome:");

        jLabel7.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel7.setText("Relatórios sobre clientes");

        jLabel8.setText("Gere a lista de clientes pelo CPF/CNPJ:");

        checkPeloNome.setText("Gere lista pelo nome");
        checkPeloNome.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                checkPeloNomeActionPerformed(evt);
            }
        });

        checkPeloCPFCNPJ.setText("Gere lista CPF/CNPJ");
        checkPeloCPFCNPJ.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                checkPeloCPFCNPJActionPerformed(evt);
            }
        });

        tabelaRelatorioClientes.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "CPF/CNPJ", "Nome", "Endereço", "Telefone"
            }
        ));
        jScrollPane1.setViewportView(tabelaRelatorioClientes);

        gerarListaPDF.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/listaClientes.png"))); // NOI18N
        gerarListaPDF.setText("Lista Inteira");
        gerarListaPDF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                gerarListaPDFActionPerformed(evt);
            }
        });

        clienteIndividualPDF.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/clienteDaLista.png"))); // NOI18N
        clienteIndividualPDF.setText("Cliente Individual");
        clienteIndividualPDF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                clienteIndividualPDFActionPerformed(evt);
            }
        });

        buscarClientes.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/search.png"))); // NOI18N
        buscarClientes.setText("Buscar Clientes");
        buscarClientes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buscarClientesActionPerformed(evt);
            }
        });

        jLabel9.setText("Gere um arquivo PDF da (e):");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(155, 155, 155)
                        .addComponent(buscarClientes, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(150, 150, 150)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(gerarListaPDF, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(clienteIndividualPDF))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 82, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel9)
                                .addGap(95, 95, 95))))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 825, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jLabel6)
                                    .addComponent(jLabel7)
                                    .addComponent(campoListaPorNome)
                                    .addComponent(jLabel8)
                                    .addComponent(campoListaPorCPFCNPJ, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE))
                                .addGap(34, 34, 34)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(checkPeloNome)
                                    .addComponent(checkPeloCPFCNPJ))))))
                .addContainerGap(115, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addComponent(jLabel7)
                .addGap(36, 36, 36)
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(campoListaPorNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(checkPeloNome))
                .addGap(18, 18, 18)
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(campoListaPorCPFCNPJ, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(checkPeloCPFCNPJ))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel9)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(gerarListaPDF)
                        .addComponent(clienteIndividualPDF))
                    .addComponent(buscarClientes))
                .addContainerGap(100, Short.MAX_VALUE))
        );

        abasRelatorio.addTab("Clientes", jPanel3);

        tabelaComprasRelatorio.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "id", "Nome do Cliente", "CPF/CNPJ", "Valor da Compra", "Desconto Dado", "Data (ano-mês-dia)"
            }
        ));
        jScrollPane2.setViewportView(tabelaComprasRelatorio);

        jLabel13.setText("Busque pela data: (Entre primeira data e segunda data):");

        comboDiaInicial.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));

        comboMesInicial.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Jan", "Fev", "Mar", "Abr", "Maio", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez" }));

        comboAnoInicial.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "2016", "2015", "2014", "2013", "2012", "2011", "2010", "2009", "2008", "2007", "2006", "2005", "2004", "2003", "2002", "2001", "2000" }));
        comboAnoInicial.setSelectedIndex(3);

        jLabel14.setText("a:");

        comboDiaFinal.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));

        comboMesFinal.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Jan", "Fev", "Mar", "Abr", "Maio", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez" }));

        comboAnoFinal.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "2016", "2015", "2014", "2013", "2012", "2011", "2010", "2009", "2008", "2007", "2006", "2005", "2004", "2003", "2002", "2001", "2000" }));
        comboAnoFinal.setSelectedIndex(3);

        jLabel10.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel10.setText("Relatórios das Vendas");

        jLabel11.setText("Busque a transação pelo ID:");

        jLabel12.setText("Busque pelo CPF/CNPJ do cliente:");

        buscarCompras.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/search.png"))); // NOI18N
        buscarCompras.setText("Buscar Compras");
        buscarCompras.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buscarComprasActionPerformed(evt);
            }
        });

        gerarNotaDeVenda.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/nota32.png"))); // NOI18N
        gerarNotaDeVenda.setText("Nota de Venda");
        gerarNotaDeVenda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                gerarNotaDeVendaActionPerformed(evt);
            }
        });

        checkIDTransacao.setText("Busque pelo ID da venda");
        checkIDTransacao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                checkIDTransacaoActionPerformed(evt);
            }
        });

        checkCPFCNPJTransacao.setText("Busque pelo CPF/CNPJ do cliente");
        checkCPFCNPJTransacao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                checkCPFCNPJTransacaoActionPerformed(evt);
            }
        });

        checkDataTransacoes.setText("Busque pela data da transação");
        checkDataTransacoes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                checkDataTransacoesActionPerformed(evt);
            }
        });

        cancelarTransacoes.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/cancel.png"))); // NOI18N
        cancelarTransacoes.setText("Cancelar");
        cancelarTransacoes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelarTransacoesActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel10)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                        .addComponent(campoBuscaID, javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(campoBuscaCPFCNPJ, javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jLabel12, javax.swing.GroupLayout.Alignment.LEADING))
                                    .addComponent(jLabel11))
                                .addGap(322, 322, 322)
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(checkIDTransacao)
                                    .addComponent(checkCPFCNPJTransacao)
                                    .addComponent(checkDataTransacoes))))
                        .addGap(0, 263, Short.MAX_VALUE)))
                .addContainerGap())
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(127, 127, 127)
                .addComponent(buscarCompras, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cancelarTransacoes, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(gerarNotaDeVenda, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(46, 46, 46))
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel13)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(comboDiaInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(comboMesInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(comboAnoInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(47, 47, 47)
                        .addComponent(jLabel14)
                        .addGap(45, 45, 45)
                        .addComponent(comboDiaFinal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(comboMesFinal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(comboAnoFinal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addComponent(jLabel10)
                .addGap(38, 38, 38)
                .addComponent(jLabel11)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(campoBuscaID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(checkIDTransacao))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel12)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(campoBuscaCPFCNPJ, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(checkCPFCNPJTransacao))
                .addGap(18, 18, 18)
                .addComponent(jLabel13)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(comboDiaInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(comboMesInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(comboAnoInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel14)
                    .addComponent(comboDiaFinal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(comboMesFinal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(comboAnoFinal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(checkDataTransacoes))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 65, Short.MAX_VALUE)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buscarCompras)
                    .addComponent(gerarNotaDeVenda)
                    .addComponent(cancelarTransacoes, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(37, 37, 37))
        );

        abasRelatorio.addTab("Vendas", jPanel4);

        jLabel16.setText("Busque o produto pelo nome");

        jLabel17.setText("Busque o produto por código");

        buscarProduto.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/search.png"))); // NOI18N
        buscarProduto.setText("Buscar");
        buscarProduto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buscarProdutoActionPerformed(evt);
            }
        });

        jLabel18.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        jLabel18.setText("Relatórios dos Produtos");

        checkCodigoProduto.setText("Busque pelo código do produto");
        checkCodigoProduto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                checkCodigoProdutoActionPerformed(evt);
            }
        });

        checkNomeProduto.setText("Busque pelo nome do produto");
        checkNomeProduto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                checkNomeProdutoActionPerformed(evt);
            }
        });

        cancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/cancel.png"))); // NOI18N
        cancelar.setText("Cancelar");
        cancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelarActionPerformed(evt);
            }
        });

        tabelaProdutosRelatorio.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Código", "Nome", "Preço", "Quantidade", "Grupo"
            }
        ));
        jScrollPane3.setViewportView(tabelaProdutosRelatorio);

        listaDeProdutos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/listaClientes.png"))); // NOI18N
        listaDeProdutos.setText("Lista de Produtos");
        listaDeProdutos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                listaDeProdutosActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel5Layout.createSequentialGroup()
                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jLabel16)
                                    .addComponent(jLabel17)
                                    .addComponent(campoBuscaCodigoProduto)
                                    .addComponent(campoBuscaNomeProduto, javax.swing.GroupLayout.PREFERRED_SIZE, 450, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(35, 35, 35)
                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(checkCodigoProduto)
                                    .addComponent(checkNomeProduto)))
                            .addComponent(jLabel18)))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 914, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGap(95, 95, 95)
                        .addComponent(buscarProduto, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(26, 26, 26)
                        .addComponent(cancelar)
                        .addGap(203, 203, 203)
                        .addComponent(listaDeProdutos)))
                .addContainerGap(26, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addComponent(jLabel18)
                .addGap(26, 26, 26)
                .addComponent(jLabel17)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(campoBuscaCodigoProduto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(checkCodigoProduto))
                .addGap(18, 18, 18)
                .addComponent(jLabel16)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(campoBuscaNomeProduto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(checkNomeProduto))
                .addGap(29, 29, 29)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cancelar)
                    .addComponent(buscarProduto, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(listaDeProdutos))
                .addGap(98, 98, 98))
        );

        abasRelatorio.addTab("Produtos", jPanel5);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(barraCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(abasRelatorio))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(barraCliente, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(abasRelatorio)
        );
    }// </editor-fold>//GEN-END:initComponents

    private void clientesRelatorioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clientesRelatorioActionPerformed
        abasRelatorio.setSelectedIndex(0);
        this.abasRelatorio.setEnabledAt(0, true);
        this.abasRelatorio.setEnabledAt(1, false);
        this.abasRelatorio.setEnabledAt(2, false);
    }//GEN-LAST:event_clientesRelatorioActionPerformed

    private void transacoesRelatorioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_transacoesRelatorioActionPerformed
        abasRelatorio.setSelectedIndex(1);
        this.abasRelatorio.setEnabledAt(0, false);
        this.abasRelatorio.setEnabledAt(1, true);
        this.abasRelatorio.setEnabledAt(2, false);
    }//GEN-LAST:event_transacoesRelatorioActionPerformed

    private void produtosRelatorioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_produtosRelatorioActionPerformed
        abasRelatorio.setSelectedIndex(2);
        this.abasRelatorio.setEnabledAt(2, true);
        this.abasRelatorio.setEnabledAt(1, false);
        this.abasRelatorio.setEnabledAt(0, false);
    }//GEN-LAST:event_produtosRelatorioActionPerformed

    private void checkPeloNomeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkPeloNomeActionPerformed
        if (checkPeloNome.isSelected()) {
            checkPeloCPFCNPJ.setSelected(false);
            campoListaPorNome.setEnabled(true);
            campoListaPorCPFCNPJ.setEnabled(false);
        }
    }//GEN-LAST:event_checkPeloNomeActionPerformed

    private void checkPeloCPFCNPJActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkPeloCPFCNPJActionPerformed
        if (checkPeloCPFCNPJ.isSelected()) {
            checkPeloNome.setSelected(false);
            campoListaPorCPFCNPJ.setEnabled(true);
            campoListaPorNome.setEnabled(false);
        }
    }//GEN-LAST:event_checkPeloCPFCNPJActionPerformed

    private void buscarClientesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buscarClientesActionPerformed
        if (campoListaPorNome.getText() != null && !campoListaPorNome.getText().equals("") && campoListaPorNome.isEnabled()) {
            clientes = controladorCliente.buscaClientesPorNome(campoListaPorNome.getText());
        } else if (campoListaPorCPFCNPJ.getText() != null && !campoListaPorCPFCNPJ.getText().equals("") && campoListaPorCPFCNPJ.isEnabled()) {
            clientes = controladorCliente.buscaClientesPorCPFCNPJ(campoListaPorCPFCNPJ.getText());
        } else {
            clientes = controladorCliente.buscaTodosOsClientes();
        }

        modelTabelaClientes.setNumRows(0);


        for (int i = 0; i < clientes.size(); i++) {
            Vector vec = new Vector();
            vec.add(0, clientes.get(i).getCpf_cnpj());
            vec.add(1, clientes.get(i).getNome());
            vec.add(2, clientes.get(i).getEndereco());
            vec.add(3, clientes.get(i).getTelefone());
            modelTabelaClientes.addRow(vec);
        }

        this.repaint();
    }//GEN-LAST:event_buscarClientesActionPerformed

    private void clienteIndividualPDFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clienteIndividualPDFActionPerformed
        if (tabelaRelatorioClientes.getSelectedRow() != -1) {
            Cliente clienteEscolhido = clientes.get(tabelaRelatorioClientes.getSelectedRow());
            ClienteIndividualPDF clientePDF = new ClienteIndividualPDF(clienteEscolhido);
            JOptionPane.showMessageDialog(this, "Relatório de cliente gerado com sucesso. Cheque-o em C:ArquivosPDF/Clientes/", "Warning", JOptionPane.WARNING_MESSAGE);
        } else {
            JOptionPane.showMessageDialog(this, "Um cliente precisa ser selecionado na Tabela", null, JOptionPane.OK_OPTION);
        }

    }//GEN-LAST:event_clienteIndividualPDFActionPerformed

    private void gerarListaPDFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_gerarListaPDFActionPerformed
        if (clientes != null && clientes.size() > 0) {
            ClienteListaPDF clienteListaPDF = new ClienteListaPDF(clientes);
            JOptionPane.showMessageDialog(this, "Relatório de lista de clientes gerado com sucesso. Cheque-o em C:ArquivosPDF/Clientes/", "Warning", JOptionPane.WARNING_MESSAGE);
        } else {
            JOptionPane.showMessageDialog(this, "Não há clientes para esta opção de busca", null, JOptionPane.OK_OPTION);
        }
    }//GEN-LAST:event_gerarListaPDFActionPerformed

    private void buscarComprasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buscarComprasActionPerformed
        int diaInicial = dias[comboDiaInicial.getSelectedIndex()];
        int diaFinal = dias[comboDiaFinal.getSelectedIndex()];
        int mesInicial = meses[comboMesInicial.getSelectedIndex()];
        int mesFinal = meses[comboMesFinal.getSelectedIndex()];
        int anoInicial = anos[comboAnoInicial.getSelectedIndex()];
        int anoFinal = anos[comboAnoFinal.getSelectedIndex()];

        if (checkIDTransacao.isSelected()) {
            compras = controladorCompra.buscaCompraPorID(Integer.parseInt(campoBuscaID.getText()));
        } else if (checkCPFCNPJTransacao.isSelected()) {
            compras = controladorCompra.buscaCompraPorCPF_CNPJ(campoBuscaCPFCNPJ.getText());
        } else if (checkDataTransacoes.isSelected()) {
            compras = controladorCompra.buscaCompraPorData(new java.sql.Date(anoInicial - 1900, mesInicial - 1, diaInicial), new Date(anoFinal - 1900, mesFinal - 1, diaFinal));
        } else {
            compras = controladorCompra.buscaTodasAsCompras();
        }

        modelCompras.setNumRows(0);

        for (int i = 0; i < compras.size(); i++) {
            Vector vec = new Vector();
            vec.add(0, compras.get(i).getId());
            vec.add(1, compras.get(i).getNomeDoCliente());
            vec.add(2, compras.get(i).getCpf_cnpjDoCliente());
            vec.add(3, compras.get(i).getPrecoTotal());
            vec.add(4, compras.get(i).getDescontoTotal());
            vec.add(5, compras.get(i).getDataDaCompra());
            modelCompras.addRow(vec);
        }

        this.repaint();
    }//GEN-LAST:event_buscarComprasActionPerformed

    private void gerarNotaDeVendaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_gerarNotaDeVendaActionPerformed
        if (tabelaComprasRelatorio.getSelectedRow() != -1) {
            Compra compraEscolhida = compras.get(tabelaComprasRelatorio.getSelectedRow());
            TransacoesNotaDeVendaPDF transacaoPDF = new TransacoesNotaDeVendaPDF(compraEscolhida);
            JOptionPane.showMessageDialog(this, "Relatório de transação gerado com sucesso. Cheque-o em C:ArquivosPDF/Transacoes/", "Warning", JOptionPane.WARNING_MESSAGE);
        } else {
            JOptionPane.showMessageDialog(this, "Uma transação precisa ser selecionada na Tabela", null, JOptionPane.OK_OPTION);
        }
    }//GEN-LAST:event_gerarNotaDeVendaActionPerformed

    private void checkIDTransacaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkIDTransacaoActionPerformed
        if (checkIDTransacao.isSelected()) {
            checkCPFCNPJTransacao.setSelected(false);
            checkDataTransacoes.setSelected(false);

            campoBuscaID.setEnabled(true);
            campoBuscaCPFCNPJ.setEnabled(false);
            comboAnoFinal.setEnabled(false);
            comboAnoInicial.setEnabled(false);
            comboDiaFinal.setEnabled(false);
            comboDiaInicial.setEnabled(false);
            comboMesFinal.setEnabled(false);
            comboMesInicial.setEnabled(false);
        }
    }//GEN-LAST:event_checkIDTransacaoActionPerformed

    private void checkCPFCNPJTransacaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkCPFCNPJTransacaoActionPerformed
        if (checkCPFCNPJTransacao.isSelected()) {
            checkIDTransacao.setSelected(false);
            checkDataTransacoes.setSelected(false);

            campoBuscaID.setEnabled(false);
            campoBuscaCPFCNPJ.setEnabled(true);
            comboAnoFinal.setEnabled(false);
            comboAnoInicial.setEnabled(false);
            comboDiaFinal.setEnabled(false);
            comboDiaInicial.setEnabled(false);
            comboMesFinal.setEnabled(false);
            comboMesInicial.setEnabled(false);
        }
    }//GEN-LAST:event_checkCPFCNPJTransacaoActionPerformed

    private void checkDataTransacoesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkDataTransacoesActionPerformed
        if (checkDataTransacoes.isSelected()) {
            checkCPFCNPJTransacao.setSelected(false);
            checkIDTransacao.setSelected(false);

            campoBuscaID.setEnabled(false);
            campoBuscaCPFCNPJ.setEnabled(false);
            comboAnoFinal.setEnabled(true);
            comboAnoInicial.setEnabled(true);
            comboDiaFinal.setEnabled(true);
            comboDiaInicial.setEnabled(true);
            comboMesFinal.setEnabled(true);
            comboMesInicial.setEnabled(true);
        }
    }//GEN-LAST:event_checkDataTransacoesActionPerformed

    private void cancelarTransacoesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelarTransacoesActionPerformed
        checkCPFCNPJTransacao.setSelected(false);
        checkIDTransacao.setSelected(false);
        checkDataTransacoes.setSelected(false);

        campoBuscaID.setEnabled(false);
        campoBuscaCPFCNPJ.setEnabled(false);
        comboAnoFinal.setEnabled(false);
        comboAnoInicial.setEnabled(false);
        comboDiaFinal.setEnabled(false);
        comboDiaInicial.setEnabled(false);
        comboMesFinal.setEnabled(false);
        comboMesInicial.setEnabled(false);

        modelCompras.setNumRows(0);
    }//GEN-LAST:event_cancelarTransacoesActionPerformed

    private void buscarProdutoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buscarProdutoActionPerformed

        if (checkNomeProduto.isSelected()) {
            produtos = controladorProduto.buscaProdutosPorNome(campoBuscaNomeProduto.getText());
        } else if (checkCodigoProduto.isSelected()) {
            produtos = controladorProduto.buscaClientesPorCodigo(campoBuscaCodigoProduto.getText());
        } else {
            produtos = controladorProduto.buscaTodosOsProdutos();
        }

        modelTabelaProdutos.setNumRows(0);

        for (int i = 0; i < produtos.size(); i++) {
            Vector vec = new Vector();
            vec.add(0, produtos.get(i).getCodigo());
            vec.add(1, produtos.get(i).getNome());
            vec.add(2, produtos.get(i).getPrecoPorUnidade());
            vec.add(3, produtos.get(i).getQuantidadeEstoque());
            vec.add(4, produtos.get(i).getTipoProduto());
            modelTabelaProdutos.addRow(vec);
        }

        this.repaint();
    }//GEN-LAST:event_buscarProdutoActionPerformed

    private void listaDeProdutosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_listaDeProdutosActionPerformed
        if (produtos != null && produtos.size() > 0) {
            ProdutosListaPDF listaProdutos = new ProdutosListaPDF(produtos);
            JOptionPane.showMessageDialog(this, "Relatório de lista de produtos gerado com sucesso. Cheque-o em C:ArquivosPDF/Transacoes/", "Warning", JOptionPane.WARNING_MESSAGE);
        } else {
            JOptionPane.showMessageDialog(this, "Não produtos para esta opção de busca", null, JOptionPane.OK_OPTION);
        }
    }//GEN-LAST:event_listaDeProdutosActionPerformed

    private void cancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelarActionPerformed
        checkCodigoProduto.setSelected(false);
        checkNomeProduto.setSelected(false);
        campoBuscaCodigoProduto.setEnabled(false);
        campoBuscaNomeProduto.setEnabled(false);
        
        modelTabelaProdutos.setNumRows(0);
    }//GEN-LAST:event_cancelarActionPerformed

    private void checkCodigoProdutoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkCodigoProdutoActionPerformed
        if (checkCodigoProduto.isSelected()) {
            checkNomeProduto.setSelected(false);
            campoBuscaNomeProduto.setEnabled(false);
            campoBuscaCodigoProduto.setEnabled(true);
        } else {
            campoBuscaCodigoProduto.setEnabled(false);
        }
    }//GEN-LAST:event_checkCodigoProdutoActionPerformed

    private void checkNomeProdutoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkNomeProdutoActionPerformed
        if (checkNomeProduto.isSelected()) {
            checkCodigoProduto.setSelected(false);
            campoBuscaNomeProduto.setEnabled(true);
            campoBuscaCodigoProduto.setEnabled(false);
        } else {
            campoBuscaNomeProduto.setEnabled(false);
        }
    }//GEN-LAST:event_checkNomeProdutoActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTabbedPane abasRelatorio;
    private javax.swing.JToolBar barraCliente;
    private javax.swing.JButton buscarClientes;
    private javax.swing.JButton buscarCompras;
    private javax.swing.JButton buscarProduto;
    private javax.swing.JTextField campoBuscaCPFCNPJ;
    private javax.swing.JTextField campoBuscaCodigoProduto;
    private javax.swing.JTextField campoBuscaID;
    private javax.swing.JTextField campoBuscaNomeProduto;
    private javax.swing.JTextField campoListaPorCPFCNPJ;
    private javax.swing.JTextField campoListaPorNome;
    private javax.swing.JButton cancelar;
    private javax.swing.JButton cancelarTransacoes;
    private javax.swing.JCheckBox checkCPFCNPJTransacao;
    private javax.swing.JCheckBox checkCodigoProduto;
    private javax.swing.JCheckBox checkDataTransacoes;
    private javax.swing.JCheckBox checkIDTransacao;
    private javax.swing.JCheckBox checkNomeProduto;
    private javax.swing.JCheckBox checkPeloCPFCNPJ;
    private javax.swing.JCheckBox checkPeloNome;
    private javax.swing.JButton clienteIndividualPDF;
    private javax.swing.JButton clientesRelatorio;
    private javax.swing.JComboBox comboAnoFinal;
    private javax.swing.JComboBox comboAnoInicial;
    private javax.swing.JComboBox comboDiaFinal;
    private javax.swing.JComboBox comboDiaInicial;
    private javax.swing.JComboBox comboMesFinal;
    private javax.swing.JComboBox comboMesInicial;
    private javax.swing.JButton gerarListaPDF;
    private javax.swing.JButton gerarNotaDeVenda;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JButton listaDeProdutos;
    private javax.swing.JButton produtosRelatorio;
    private javax.swing.JTable tabelaComprasRelatorio;
    private javax.swing.JTable tabelaProdutosRelatorio;
    private javax.swing.JTable tabelaRelatorioClientes;
    private javax.swing.JButton transacoesRelatorio;
    // End of variables declaration//GEN-END:variables
}
